package com.dyylearn.exception_;

public class Exception02 {
    public static void main(String[] args) {
        //NullPointerException空指针异常
//        String name = null;
//        System.out.println(name.length());

        //ArraylndexOutOfBoundsException数组下标越界异常
//        int[] arr = {1, 2, 3};
//        for (int i = 0; i <= arr.length; i++) {
//            System.out.println(arr[i]);
//        }

        //ClassCastException类型转换异常
//        A b = new B();//向上转型
//        B b2 = (B)b;//向下转型，ok
//        C c2 = (C)b;//会抛出ClassCastException异常

        //5)NumberFormatException数字格式不正确异常[]
        String name = "张三";
        int num = Integer.parseInt(name);
        System.out.println(num);
    }
}

class A{}
class B extends A {}
class C extends A {}


